﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OnLineExam.BLL;

namespace OnLineExam.Web.mag.old
{
    public partial class pwdMoify : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = "修改密码";
            if (!Page.IsPostBack)
            {

                string userId = User.Identity.Name;
                //string userName = UserManager.GetUserName(userId);
                //Label i = (Label)Page.Master.FindControl("labUser");
                //i.Text = userName;

            }
        }
        protected void imgBtnModifyPwd_Click1(object sender, ImageClickEventArgs e)
        {
            string userId = User.Identity.Name;
            string newPwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtNewPwd.Text.Trim(), "MD5").ToString();
            string pwdMd5 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtOldPwd.Text.Trim(), "MD5").ToString();
            if (UserManager.GetSelectPwd(pwdMd5))
            {

                UserManager.ModifyPwd(newPwd, userId);
                lblMessage.Text = "修改成功！";
                this.txtOldPwd.Text = string.Empty;
            }
            else
            {
                lblMessage.Text = "原密码不正确！";
            }
        }
        protected void imgBtnReset_Click(object sender, ImageClickEventArgs e)
        {
            txtOldPwd.Text = txtNewPwd.Text = txtConfirmPwd.Text = "";
            lblMessage.Text = "";
        }
    }
}